package com.kgcx.opc.rabbit.receiver;

import com.google.gson.Gson;
import com.kgcx.common.rabbitmq.bean.Message;
import com.kgcx.opc.service.AssignService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 何凯
 * @version 0.1
 * @description
 * @time 2017/11/14 13:57
 * @since 0.1
 */
//@Component
//@RabbitListener(queues = "queue")
public class MQReceiver {
    @Autowired
    private AssignService assignService;
    //@RabbitHandler
    public  void processMessage(String message){
       try {
           Gson gson= new Gson();
           Message messages = gson.fromJson(message,Message.class);
           assignService.forwordApi(messages);
           System.out.println("Received contract<" + messages.getId() + ">");
       } catch (Exception e) {
         }
    }
}
